<template>
  <el-header style="color: darkmagenta ;font-size: large"><strong>请添新员工</strong></el-header>
  <el-form :model="pForm" status-icon  ref="ruleForm" label-width="100px" class="demo-ruleForm">
    <el-form-item label="Name" prop="pName">
      <el-input type="name" v-model="pForm.pName" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="年龄" prop="pAge">
      <el-input type="number" v-model="pForm.pAge" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="性别" prop="pSex">
<!--      <el-input type="text" v-model="pForm.pSex" autocomplete="off"></el-input>-->
      <el-radio-group v-model="pForm.pSex">
        <el-radio label="男"></el-radio>
        <el-radio  label="女"></el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="部门" prop="pClass">
      <el-input type="text" v-model="pForm.pClass" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="入职时间" prop="pJoin">
      <el-input type="date" v-model="pForm.pJoin" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="TEL" prop="pTel">
      <el-input type="text" v-model="pForm.pTel" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="submitForm">提交</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
name: "addPersonnel",
  data() {
    return {
      pForm: {
        pName: '',
        pAge:'',
        pSex:'男',
        pClass:'',
        pJoin:'',
        pTel:''
      },
    };
  },
  methods: {
    submitForm(){
      //提交表单到后端
      this.$http.post("http://localhost:8989/Personnel/add",this.pForm).then(res=>{
        console.log(res.data);
        if(res.data.status){
          this.$message({
            message:'恭喜你'+res.data.msg,
            type:'success'
          })
        //  成功后的处理：清空表单信息
          this.pForm={};
          this.$emit('findAll');
        }else {
          this.$message.error(this.date.msg);
        }
      })
    },
  }
}
</script>

<style scoped>

</style>